<template>
  <div class="wfull">
    <a-form :labelCol="{ span: 4 }" :wrapperCol="{ span: 20 }">
<#list batchList as pro>
<#if pro.compType??>
<#if pro.compType=="text">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgInput v-model="obj.${pro.name}"></ZgInput>
      </a-form-item>
</#if>
<#if pro.compType=="textarea">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgTextarea v-model="obj.${pro.name}"></ZgTextarea>
      </a-form-item>
</#if>
<#if pro.compType=="select">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgSelect v-model="obj.${pro.name}" :options="dic.${pro.name}Opts"></ZgSelect>
      </a-form-item>
</#if>
<#if pro.compType=="radio">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgRadio v-model="obj.${pro.name}" :options="dic.${pro.name}Opts"></ZgRadio>
      </a-form-item>
</#if>
<#if pro.compType=="checkbox">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgCheckbox v-model="obj.${pro.name}"></ZgCheckbox>
      </a-form-item>
</#if>
<#if pro.compType=="int">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgNumber v-model="obj.${pro.name}"></ZgNumber>
      </a-form-item>
</#if>
<#if pro.compType=="double">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgNumber isFloat v-model="obj.${pro.name}"></ZgNumber>
      </a-form-item>
</#if>
<#if pro.compType=="switch">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgSwitch v-model="obj.${pro.name}"></ZgSwitch>
      </a-form-item>
</#if>
<#if pro.compType=="date">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgDatePicker v-model="obj.${pro.name}"></ZgDatePicker>
      </a-form-item>
</#if>
<#if pro.compType=="datetime">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgDateTimePicker v-model="obj.${pro.name}"></ZgDateTimePicker>
      </a-form-item>
</#if>
<#if pro.compType=="time">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgTimePicker v-model="obj.${pro.name}"></ZgTimePicker>
      </a-form-item>
</#if>
<#if pro.compType=="tags">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgTags v-model="obj.${pro.name}_arr"></ZgTags>
      </a-form-item>
</#if>
<#if pro.compType=="img">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgUpImg v-model="obj.${pro.name}"></ZgUpImg>
      </a-form-item>
</#if>
<#if pro.compType=="attach">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgUpFile v-model="obj.${pro.name}_arr"></ZgUpFile>
      </a-form-item>
</#if>
<#if pro.compType=="tinymce">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgTinymce v-model="obj.${pro.name}"></ZgTinymce>
      </a-form-item>
</#if>
<#if pro.compType=="dic">
      <a-form-item>
        <template slot="label">
          <ZgCheckbox v-model="obj.${pro.name}Ck">${pro.columnVo.comment}</ZgCheckbox>
        </template>
        <ZgDictionary v-model="obj.${pro.name}" code="${pro.genColumn.dicCode!"sex"}"></ZgDictionary>
      </a-form-item>
</#if>
</#if>
</#list>
    </a-form>
  </div>
</template>
<script>
import { dic } from './dic'
export default {
  props: {
    ids: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      dic,
      obj: {
<#list batchList as pro>
<#if pro.compType??>
        ${pro.name}Ck: false,
<#if pro.compType=="select"||pro.compType=="radio"||pro.compType=="text"||pro.compType=="textarea"||pro.compType=="date"||pro.compType=="datetime"||pro.compType=="time"||pro.compType=="img"||pro.compType=="tinymce"||pro.compType=="dic">
        ${pro.name}: '',
</#if>
<#if pro.compType=="int">
        ${pro.name}: 0,
</#if>
<#if pro.compType=="double">
        ${pro.name}: 0.0,
</#if>
<#if pro.compType=="switch"||pro.compType=="checkbox">
        ${pro.name}: false,
</#if>
<#if pro.compType=="attach"||pro.compType=="tags">
        ${pro.name}: '',
        ${pro.name}_arr: [],
</#if>
</#if>
</#list>
        id: '0'
      }
    }
  },
  methods: {
    save () {
      if (
<#list batchList as pro>
<#if pro.compType??>
        this.obj.${pro.name}Ck === false &&
</#if>
</#list>
        true) {
        return this.$result.error('请选择要设置的属性')
      }
<#list batchList as pro>
<#if pro.compType??>
<#if pro.compType=="text"||pro.compType=="textarea"||pro.compType=="select"||pro.compType=="radio"||pro.compType=="date"||pro.compType=="datetime"||pro.compType=="time"||pro.compType=="img"||pro.compType=="tinymce"||pro.compType=="dic">
      if (this.obj.${pro.name}Ck === true && this.obj.${pro.name}.length === 0) {
        return this.$result.error('请输入${pro.columnVo.comment}')
      }
</#if>
<#if pro.compType=="tags"||pro.compType=="attach">
      if (this.obj.${pro.name}Ck === true && this.obj.${pro.name}_arr.length === 0) {
        return this.$result.error('请设置${pro.columnVo.comment}')
      }
</#if>
</#if>
</#list>
<#list batchList as pro>
<#if pro.compType??>
<#if pro.compType=="tags"||pro.compType=="attach">
      this.obj.${pro.name} = JSON.stringify(this.obj.${pro.name}_arr)
</#if>
</#if>
</#list>
      return this.$result.ok(Object.assign({ idList: this.ids }, this.obj))
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
